package eerbaar.client.internal.ctr.operator;

import eerbaar.client.ctr.OperatorConstants;
import eerbaar.client.exp.IExp;
import eerbaar.client.exp.IOperatorFactory;

public class OperatorFactory implements IOperatorFactory {

    public OperatorFactory() {
        //
    }

    @Override
    public IExp create(IExp[] array, String string) {

        if (string.equals(OperatorConstants.RANDOM)) {

            return new GotoRandom();
        }

        if (string.equals(OperatorConstants.ATTRACT)) {

            return new Attract(array);
        }
        if (string.equals(OperatorConstants.REPEL)) {

            return new Repel(array);
        }
        if (string.equals(OperatorConstants.REPEL_STRONG)) {

            return new RepelStrong(array);
        }
        if (string.equals(OperatorConstants.ADD)) {

            return new Add(array);
        }

        return null;
    }

    @Override
    public boolean isOperator(String string) {

        if (string.equals("{seq}")) {

            return true;
        }
        if (string.equals(OperatorConstants.ATTRACT)) {

            return true;
        }
        if (string.equals(OperatorConstants.RANDOM)) {

            return true;
        }
        if (string.equals(OperatorConstants.REPEL)) {

            return true;
        }
        if (string.equals(OperatorConstants.REPEL_STRONG)) {

            return true;
        }
        if (string.equals(OperatorConstants.ADD)) {

            return true;
        }

        return false;
    }

}
